<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ws_client</title>
</head>
<body>
<h1>ws_client 测试websockte</h1>
<script>
    var url = "ws://swoole.kinggui.com:8899";
    var ws = new WebSocket(url);
    //
    ws.onopen = function (evt) {
        ws.send("cao ht,js zhe liang ge bi!");
        console.log('connected success!');
    }
    ws.onmessage = function (evt) {
        console.log(evt.data);
    }
    ws.onclose = function (evt) {
        console.log('disconnnected!');
    }
    ws.onerror = function (evt) {
        console.log('occur a wrong');
    }
</script>
</body>
</html>